#pragma once

#include "../../select/select.hpp"
#include "qlib/all.h"

#include "../../ecs/query.hpp"

#include "../../select/select_cmd.hpp"

namespace qbe::quickAlign {

// 移动功能流程
enum struct State { None = 0, Wait, Cancel };

// 移动参数 [资源]
struct Param {
  State state = State::None;  // 处于什么流程

  bool tag_select_obj = false;

  qlib::Vec2d dis;

  bool isPointAlign;
  bool haveOnePoint = false;
  qlib::Vec2d pos;

  bool haveOneLine = false;
  qlib::Vec2dArray line;

  double k = 0;
  bool dx_eaual_0 = false;
  double length = 0;

  bool use_default_quick_align = false;
  bool last_is_point = true;

  std::unordered_map<entt::entity, select::SelectPartData> partMap;

  bool isStretch = false;
  std::unordered_map<entt::entity, select::SelectPartData> stretchPartMap;

  bool quick_first = true;

  void reset() {
    state = State::None;

    tag_select_obj = false;

    dis = qlib::Vec2d(0, 0);

    isPointAlign = true;
    haveOnePoint = false;
    pos = qlib::Vec2d(0, 0);

    haveOneLine = false;
    line.clear();

    use_default_quick_align = false;
    partMap.clear();

    isStretch = false;
    stretchPartMap.clear();

    quick_first = true;
  }

  void exit_total(ecs::Query& query) {
    auto& select_cmd = query.get_resource<select::SelectCmd>();
    select_cmd.clear_parts();
    select_cmd.algin_clear_select_parts();
    select_cmd.clear_hover_parts();
  }

  bool need_change = false;
};

}  // namespace qbe::quickAlign